package com.weather.controller;

import com.weather.domen.AreaDomeService;
import com.weather.pojo.entity.AreaInfo;
import com.weather.pojo.vo.AreaInfoVO;
import com.weather.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/area")
@Api(tags = "设备投放区域管理")
public class AreaController {


    @Resource
    private AreaDomeService areaDomeService;

    @GetMapping("/getAreaInfoList")
    @ApiOperation(value = "获取设备投放区域列表")
    public R<List<AreaInfoVO>> getAreaInfoList() {
        return R.ok(areaDomeService.getAreaInfoList());
    }

    @PostMapping("/addAreaInfo")
    @ApiOperation(value = "添加设备投放区域")
    public R<Boolean> addAreaInfo(@RequestBody AreaInfo areaInfo) {
        return R.ok(areaDomeService.addAreaInfo(areaInfo));
    }

    @PutMapping("/updateAreaInfo")
    @ApiOperation(value = "修改设备投放区域")
    public R<Boolean> updateAreaInfo(@RequestBody AreaInfo areaInfo) {
        return R.ok(areaDomeService.updateAreaInfo(areaInfo));
    }

    @DeleteMapping("/deleteAreaInfo/{areaId}")
    @ApiOperation(value = "删除设备投放区域")
    public R<Boolean> deleteAreaInfo(@PathVariable Long areaId) {
        return R.ok(areaDomeService.deleteAreaInfo(areaId));
    }
}
